
import BaseInputMgr from "./BaseInputMgr";


export class KeyInputMgr  {
    private static ins: KeyInputMgr;

    static instance() {
        if (!this.ins) {
            this.ins = new KeyInputMgr()
        }
        return this.ins;
    }
    protected _inputMgr: BaseInputMgr[] = [];


    pushInput(l: BaseInputMgr) {
        l.init()
        this._inputMgr.push(l)
    }

    hasInputMgr() {
        return this._inputMgr != null;
    }

    clear() {
        for (let index = 0; index < this._inputMgr.length; index++) {
            const element = this._inputMgr[index];
            element.clear()
        }
    }

    update(deltaTime: number) {
        for (let index = 0; index < this._inputMgr.length; index++) {
            const element = this._inputMgr[index];
            element.update(deltaTime)
        }
    }
}